﻿using System;
using System.Windows.Data;

namespace ReflectionStudio.Controls
{
    /// <summary>
    /// Converter : Enum to string and revert
    /// </summary>
    [ValueConversion(typeof(string), typeof(string))]
    public class Divideby100 : IValueConverter
    {
        /// <summary>
        /// IValueConverter.Convert
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.ToString().Trim() == "")
                value = 0;
           return (System.Convert.ToDecimal(value.ToString()) / 100).ToString();
        }

        /// <summary>
        /// IValueConverter.ConvertBack
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.ToString().Trim() == "")
                value = 0;
            return (System.Convert.ToDecimal(value.ToString()) * 100).ToString();
        }
    }
    /// <summary>
    /// Converter : Enum to string and revert
    /// </summary>
    [ValueConversion(typeof(string), typeof(string))]
    public class Divideby10 : IValueConverter
    {
        /// <summary>
        /// IValueConverter.Convert
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if(value.ToString().Trim()=="")
                value=0;
            return (System.Convert.ToDecimal(value.ToString()) / 10).ToString();
        }

        /// <summary>
        /// IValueConverter.ConvertBack
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.ToString().Trim() == "")
                value = 0;
            return (System.Convert.ToDecimal(value.ToString()) * 10).ToString();
        }
    }
    /// <summary>
    /// Converter : Enum to string and revert
    /// </summary>
    [ValueConversion(typeof(string), typeof(string))]
    public class Divideby1000 : IValueConverter
    {
        /// <summary>
        /// IValueConverter.Convert
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.ToString().Trim() == "")
                value = 0;
            return (System.Convert.ToDecimal(value.ToString()) / 1000).ToString();
        }

        /// <summary>
        /// IValueConverter.ConvertBack
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.ToString().Trim() == "")
                value = 0;
            return (System.Convert.ToDecimal(value.ToString()) * 1000).ToString();
        }
    }
    /// <summary>
    /// Converter : Enum to string and revert
    /// </summary>
    [ValueConversion(typeof(string), typeof(string))]
    public class Divideby10000 : IValueConverter
    {
        /// <summary>
        /// IValueConverter.Convert
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.ToString().Trim() == "")
                value = 0;
            return (System.Convert.ToDecimal(value.ToString()) / 10000).ToString();
        }

        /// <summary>
        /// IValueConverter.ConvertBack
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.ToString().Trim() == "")
                value = 0;
            return (System.Convert.ToDecimal(value.ToString()) * 10000).ToString();
        }
    }
     /// <summary>
    /// Converter : Enum to string and revert
    /// </summary>
    [ValueConversion(typeof(string), typeof(string))]
    public class MaskPrice : IValueConverter
    {
        /// <summary>
        /// IValueConverter.Convert
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.ToString().Trim() == "")
                value = 0;
            return (System.Convert.ToDecimal(value.ToString())*3 / 2000).ToString();
        }

        /// <summary>
        /// IValueConverter.ConvertBack
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value.ToString().Trim() == "")
                value = 0;
            return (System.Convert.ToDecimal(value.ToString()) * 2000/3).ToString();
        }
    }
    
}
